package com.fnzn.entranceGuard.service.sys.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.fnzn.entranceGuard.entity.sys.SysDept;
import com.fnzn.entranceGuard.entity.sys.SysUser;
import com.fnzn.entranceGuard.mapper.sys.SysUserMapper;
import com.fnzn.entranceGuard.service.sys.SysUserService;
import com.github.pig.common.vo.UserVO;
import com.netflix.discovery.converters.Auto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author lengleng
 * @date 2017/10/31
 */
@Slf4j
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {

    @Autowired
    private SysUserMapper sysUserMapper;

    @Override
    public UserVO findUserByUsername(String username) {
        return sysUserMapper.selectUserVoByUsername(username);
    }

    @Override
    public List<UserVO> findEstatesByUsername(String username, String communityId  ) {
        return sysUserMapper.findEstatesByUsername(username,communityId);
    }
    @Override
    public SysDept findCompanyByUserName(String username,String property) {
       List<SysDept> list =  sysUserMapper.findCompanyByUserName(username,property);
       if(list!=null && !list.isEmpty()){
            return list.get(0);
        }
        return null;
    }
}
